// TestRegularPolygon.java
public class TestRegularPolygon {
    public static void main(String[] args) {
        // Create three RegularPolygon objects
        RegularPolygon poly1 = new RegularPolygon();
        RegularPolygon poly2 = new RegularPolygon(6, 4);
        RegularPolygon poly3 = new RegularPolygon(10, 4, 5.6, 7.8);

        // Display objects using toString method
        System.out.println("Polygon 1: " + poly1);
        System.out.println("Polygon 2: " + poly2);
        System.out.println("Polygon 3: " + poly3);
        
        // Test additional functionality
        System.out.println("\nAdditional Tests:");
        System.out.println("Polygon 1 Area: " + String.format("%.2f", poly1.getArea()));
        System.out.println("Polygon 2 Perimeter: " + String.format("%.2f", poly2.getPerimeter()));
        System.out.println("Polygon 3 Area: " + String.format("%.2f", poly3.getArea()));
    }
}

class RegularPolygon {
    private int n;        // number of sides
    private double side;  // length of side
    private double x;     // x-coordinate of center
    private double y;     // y-coordinate of center

    // No-arg constructor with default values
    public RegularPolygon() {
        this.n = 3;
        this.side = 1;
        this.x = 0;
        this.y = 0;
    }

    // Constructor with specified sides and length, centered at (0,0)
    public RegularPolygon(int n, double side) {
        this.n = n;
        this.side = side;
        this.x = 0;
        this.y = 0;
    }

    // Constructor with all specified values
    public RegularPolygon(int n, double side, double x, double y) {
        this.n = n;
        this.side = side;
        this.x = x;
        this.y = y;
    }

    // Accessor methods
    public int getN() {
        return n;
    }

    public double getSide() {
        return side;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    // Mutator methods
    public void setN(int n) {
        this.n = n;
    }

    public void setSide(double side) {
        this.side = side;
    }

    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }

    // Calculate perimeter
    public double getPerimeter() {
        return n * side;
    }

    // Calculate area using the formula: Area = (n * s²) / (4 * tan(π/n))
    public double getArea() {
        return (n * side * side) / (4 * Math.tan(Math.PI / n));
    }

    // toString method
    @Override
    public String toString() {
        return "RegularPolygon{" +
                "n=" + n +
                ", side=" + side +
                ", x=" + x +
                ", y=" + y +
                ", perimeter=" + String.format("%.2f", getPerimeter()) +
                ", area=" + String.format("%.2f", getArea()) +
                '}';
    }
}